<template>
  <div class="cart">
    <!-- 导航 -->
    <nav-bar class="nav-bar">
      <div slot="center">购物车({{ cartLength }})</div>
    </nav-bar>
    <!-- 商品列表-->
    <cart-list></cart-list>
    <!-- 底部汇总 -->
    <cart-bottom-nav></cart-bottom-nav>
  </div>
</template>

<script>
import NavBar from "@/components/common/navbar/NavBar";
import {mapGetters} from 'vuex';
import CartList from "@/views/cart/childComps/CartList";
import CartBottomNav from "@/views/cart/childComps/CartBottomNav";

export default {
  name: "Cart",
  components: {CartBottomNav, CartList, NavBar},
  data() {
    return {}
  },
  computed: {
    //辅助函数...mapGetters   直接将store中的Getters映射到局部计算属性
    ...mapGetters(
      //用法一：
      //["getCartLength", "getCartList"]
      //用法二：
      {
        cartLength: 'getCartLength',
        cartList: 'getCartLength'
      }
    )
  }

}
</script>

<style scoped>
/*.cart{
  height: 100vh;
}*/
.nav-bar {
  background-color: var(--color-tint);
  color: #fff;
}
</style>
